package com.wky.system.service.impl;

import com.wky.basic.Result.PageResult;
import com.wky.basic.service.impl.BaseServiceImpl;
import com.wky.org.mapper.EmployeeMapper;
import com.wky.org.pojo.Department;
import com.wky.org.pojo.Employee;
import com.wky.org.service.DepartmentService;
import com.wky.system.mapper.SystemDetailMapper;
import com.wky.system.mapper.SystemTypeMapper;
import com.wky.system.pojo.SystemDetail;
import com.wky.system.pojo.SystemType;
import com.wky.system.service.SystemDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SystemDetailServicerImpl extends BaseServiceImpl<SystemDetail> implements SystemDetailService {
    @Autowired
    private SystemDetailMapper systemDetailMapper;
    @Autowired
    private SystemTypeMapper systemTypeMapper;

    public PageResult<SystemDetail> findByPage(SystemDetail systemDetail) {
        List<SystemDetail> pageResult = systemDetailMapper.findByPage(systemDetail);
        for (SystemDetail detail : pageResult) {
            SystemType type = systemTypeMapper.findById(detail.getTypesId());
            detail.setTypes(type);
        }

        Integer total = systemDetailMapper.findTotal(systemDetail);

        return new PageResult<>(total, pageResult);
    }
}
